<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="退款单号">
              <a-input placeholder="请输入退款单号" v-model="queryParam.refundNo"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="订单号">
              <a-input placeholder="请输入订单号" v-model="queryParam.orderNo"></a-input>
            </a-form-item>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="商品名称">
              <a-input placeholder="请输入售商品名称" v-model="queryParam.title"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="用户昵称">
              <a-input placeholder="请输入用户昵称" v-model="queryParam.nickname"></a-input>
            </a-form-item>
          </a-col>
          <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="用户手机号">
              <a-input placeholder="请输入用户手机号称" v-model="queryParam.phone"></a-input>
            </a-form-item>
          </a-col> -->
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="退款状态">
              <!-- <a-input placeholder="请输入状态：1=待处理，2=同意并退款，3=已拒绝 ,4=已关闭" v-model="queryParam.status"></a-input> -->
              <a-select :default-value="null" v-model="queryParam.status" @change="searchQuery">
                <a-select-option :value="null">
                  全部
                </a-select-option>
                <a-select-option :value="1">
                  待处理
                </a-select-option>
                <a-select-option :value="2">
                  同意并退款
                </a-select-option>
                <a-select-option :value="3">
                  已拒绝
                </a-select-option>
                <a-select-option :value="4">
                  已关闭
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="创建时间">
              <a-range-picker format="YYYY-MM-DD" :placeholder="['开始时间', '结束时间']" @change="onDateChange" />
            </a-form-item>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>

               <a-button type="primary" icon="download" @click="handleExportXls('售后订单')" style="margin-left: 8px">导出</a-button>

            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    <!-- table区域-begin -->
    <div>

      <a-table ref="table" size="middle" :scroll="{x:true}" bordered rowKey="refundNo" :columns="shopType==4?columns1:columns"
        :dataSource="dataSource" :pagination="ipagination" :loading="loading"
        class="j-table-force-wrap" @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>

        <template slot="goodInfo" slot-scope="text,record">
          <div v-for="(item,index) in record.orderSkuList" :key="index" :class="record.orderSkuList.length==index+1?'':'b-b'">
            <div style="display:flex;">
              <div style="padding:4px;">
                <img style="width:40px;" :src="item.imgUrl">
              </div>
              <div style="flex:1;padding:4px;text-align:left;min-height:62px;">
                <div style="width:100px;white-space: normal;word-break: break-all;word-wrap: break-word;color:#333333;line-height:18px;">
                  {{ item.spuName }}</div>
                <div style='margin-top: 5px;width:100px;white-space: normal;word-break: break-all;word-wrap: break-word;font-size:12px;'>
                  {{ item.skuName }}
                </div>
              </div>
              <div style="width:100px;text-align:left;padding:4px;min-height:62px;">
                <div v-if="shopType!=4">
                  <b>金额：</b>{{ item.subTotal+item.changePrice-item.couponDiscount-item.shopCouponDiscount-item.integralDiscount|numToFixed2 }}
                </div>
                <b>数量：</b>{{ item.num }}件
              </div>

            </div>
          </div>

        </template>
        <template slot="memberInfo" slot-scope="text,record">
          <div>{{record.member.nickname}}</div>
        </template>
        <template slot="shopInfo" slot-scope="text,record">
          <div>{{record.shop.name}}<br>{{ record.supplier?'(供应商：'+record.supplier.name+')':'' }}</div>
        </template>
        <template slot="orderInfo" slot-scope="text,record">
          <div v-for="(item,index) in record.orderSkuList" :key="index">
            {{ item.subSupplyPrice|numToFixed2 }}
          </div>
        </template>
        <template slot="number" slot-scope="text">
          <div>
            {{text|numToFixed2}}
          </div>
        </template>
        <template slot="preStatusSlot" slot-scope="text,record">
          <div>
            {{record.status==1?record.preStatus_dictText:record.status_dictText}}
          </div>
        </template>

        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="55px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;" />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <template slot="action" slot-scope="text, record">
          <div>
            <a @click="handleEdit(record)">详情</a>
          </div>
          <div v-if="record.type==1">
            <!-- 自营商品 -->
            <div v-if="record.shopId=='A00001A00001'&&!record.supplierId&&shopType==1">
              <!-- 1-1.平台初审-通过 -->
              <div>
                <a v-if="record.preStatus==0&&record.status==1" @click="handleShopAddress(record)">确认退货地址</a>
              </div>
              <!-- 1-2.平台初审-拒绝 -->
              <div>
                <a v-if="record.preStatus==0&&record.status==1" @click="handleMallRefuse(record)">拒绝退款</a>
              </div>
              <!-- 3-1.店铺处理-货物审核通过 》 平台终审 -->
              <div>
                <a v-if="record.preStatus==4&&record.status==1" @click="handleMallLastAgree(record)">审核通过</a>
              </div>
              <!-- 3-2.店铺处理-货物审核拒绝 》 平台终审 -->
              <div>
                <a v-if="record.preStatus==4&&record.status==1" @click="handleMallLastRefuse(record)">拒绝退款</a>
              </div>
            </div>
            <!-- 供应商商品 -->
            <div v-else-if="record.shopId=='A00001A00001'&&record.supplierId">
              <!-- 1-1.平台初审-通过 -->
              <div>
                <a v-if="record.preStatus==0&&record.status==1&&shopType==1" @click="handleMallAgree(record)">审核通过</a>
              </div>
              <!-- 1-2.平台初审-拒绝 -->
              <div>
                <a v-if="record.preStatus==0&&record.status==1&&shopType==1" @click="handleMallRefuse(record)">拒绝退款</a>
              </div>
              <!-- 2-1.店铺处理-确认退货地址 》 待用户发货 -->
              <div>
                <a v-if="record.preStatus==1&&record.status==1&&shopType==4" @click="handleShopAddress(record)">确认退货地址</a>
              </div>
              <!-- 3-1.店铺处理-货物审核通过 》 平台终审 -->
              <div>
                <a v-if="record.preStatus==4&&record.status==1&&shopType==4" @click="handleShopGoodAgree(record)">货物审核通过</a>
              </div>
              <!-- 3-2.店铺处理-货物审核拒绝 》 平台终审 -->
              <div>
                <a v-if="record.preStatus==4&&record.status==1&&shopType==4" @click="handleShopGoodRefuse(record)">货物审核拒绝</a>
              </div>
              <!-- 4-1.平台终审-通过 -->
              <div>
                <a v-if="(record.preStatus==5||record.preStatus==6)&&record.status==1&&shopType==1" @click="handleMallLastAgree(record)">审核通过</a>
              </div>
              <!-- 4-2.平台终审-拒绝 -->
              <div>
                <a v-if="(record.preStatus==5||record.preStatus==6)&&record.status==1&&shopType==1" @click="handleMallLastRefuse(record)">拒绝退款</a>
              </div>
            </div>

            <!-- 店铺商品 -->
            <div v-else>

              <!-- 1-2.店铺初审-拒绝 -->
              <div>
                <a v-if="record.preStatus==0&&record.status==1&&shopType==3" @click="handleMallRefuse(record,type)">拒绝退款</a>
              </div>
              <!-- 2-1.店铺初审-确认退货地址 》 待用户发货 -->
              <div>
                <a v-if="record.preStatus==0&&record.status==1&&shopType==3" @click="handleShopAddress(record)">审核通过</a>
              </div>
              <!-- 3-1.店铺处理-货物审核通过 》 平台终审 -->
              <!-- <div>
                <a v-if="record.preStatus==4&&record.status==1&&shopType==3" @click="handleShopGoodAgree(record)">货物审核通过</a>
              </div> -->
              <!-- 4-1.平台终审-通过 -->
              <div>
                <a v-if="(record.preStatus==4||record.preStatus==5||record.preStatus==6)&&record.status==1&&shopType==3"
                  @click="handleMallLastAgree(record,2)">审核通过</a>
              </div>
              <!-- 4-2.平台终审-拒绝 -->
              <div>
                <a v-if="(record.preStatus==4||record.preStatus==5||record.preStatus==6)&&record.status==1&&shopType==3"
                  @click="handleMallLastRefuse(record,2)">拒绝退款</a>
              </div>
              <!-- 关闭订单 -->
              <div>
                <a v-if="shopType==1&&(record.status==1||record.status==3)" @click="handleMallLastAgree(record,null,1)">关闭订单</a>
              </div>
            </div>

          </div>

          <div v-if="record.type==2&&record.status==1">
            <!-- 4-1.平台终审-通过 -->
            <div>
              <a v-if="record.preStatus==0&&((shopType==1&&record.shopId=='A00001A00001')||shopType==3)" @click="handleMallLastAgree(record)">审核通过</a>
            </div>
            <!-- 4-2.平台终审-拒绝 -->
            <div>
              <a v-if="record.preStatus==0&&((shopType==1&&record.shopId=='A00001A00001')||shopType==3)"
                @click="handleMallLastRefuse(record)">拒绝退款</a>
            </div>
            <!-- 关闭订单 -->
            <div>
              <a v-if="shopType==1&&record.shopId!='A00001A00001'&&(record.status==1||record.status==3)"
                @click="handleMallLastAgree(record,null,1)">关闭订单</a>
            </div>
          </div>

        </template>

      </a-table>
    </div>

    <oms-order-refund-modal ref="modalForm" @ok="modalFormOk"></oms-order-refund-modal>
    <!-- 平台初审-拒绝 -->
    <a-modal title="拒绝原因" :visible="mallRefuseVisible" :confirm-loading="confirmLoading" @ok="handleMallRefuseOk" @cancel="mallRefuseVisible= false">
      拒绝原因：
      <a-input placeholder="请输入拒绝原因" v-model="refuseReason" />
    </a-modal>
    <!-- 店铺处理-确认退款地址 -->
    <a-modal title="确认退款地址" :visible="shopAddressVisible" :confirm-loading="confirmLoading" @ok="handleShopAddressOk"
      @cancel="shopAddressVisible= false">
      退款地址：
      <a-input style="height:0px;height:0px;opacity: 0;" placeholder="请输入退款地址id" v-model="addressId" />
      <a-input placeholder="请选择退款地址" :disabled="true" v-model="name" />
      <a-input placeholder="请选择退款地址" :disabled="true" v-model="tel" />
      <a-input placeholder="请选择退款地址" :disabled="true" v-model="postCode" />
      <a-input placeholder="请选择退款地址" :disabled="true" v-model="addressName" />
      <a-button style="margin:10px 0;" @click="addressSelect">选择地址</a-button>
    </a-modal>
    <!-- 店铺处理-货物审核拒绝 -->
    <a-modal title="拒绝原因" :visible="shopGoodRefuseVisible" :confirm-loading="confirmLoading" @ok="handleShopGoodRefuseOk"
      @cancel="shopGoodRefuseVisible= false">
      拒绝原因：
      <a-input placeholder="请输入拒绝原因" v-model="refuseReason" />
    </a-modal>
    <!-- 平台终审-通过 -->
    <a-modal :title="isClose==1?'关闭退款单':'同意退款'" :visible="mallLastAgreeVisible" :confirm-loading="confirmLoading" @ok="handleMallLastAgreeOk"
      @cancel="mallLastAgreeVisible= false">
      <!-- <div>
        订单金额：{{max_refund_amount}}
      </div> -->
      <div>
        退款金额：
        <a-input-number placeholder="请输入退款金额" :min="0.01" :precision="2" v-model="refundPrice" :max="max_refund_amount" />
      </div>
      <div v-if="isClose==1" style="margin-top:15px;">
        处理备注：
        <a-input placeholder="请输入关闭原因" v-model="closeReason" />
      </div>

    </a-modal>
    <!-- 平台初审-拒绝 -->
    <a-modal title="拒绝原因" :visible="mallLastRefuseVisible" :confirm-loading="confirmLoading" @ok="handleMallLastRefuseOk"
      @cancel="mallLastRefuseVisible= false">
      拒绝原因：
      <a-input placeholder="请输入拒绝原因" v-model="refuseReason" />
    </a-modal>
    <oms-refund-address-ref ref="modalGoodsSet" @ok=" modalGoodsOk" />

  </a-card>
</template>

<script>
import Vue from 'vue'
import { SHOP_TYPE, ORG_CODE } from "@/store/mutation-types"
import { postAction, getAction } from '@/api/manage'
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/MyJeecgListMixin'
import OmsOrderRefundModal from './modules/OmsOrderRefundModal'
import OmsRefundAddressRef from '@/views/gospel/mallBase/shop/modules/OmsRefundAddressRef'
import JDate from '@/components/jeecg/JDate.vue'

export default {
  name: 'OmsOrderRefundList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    JDate,
    OmsOrderRefundModal,
    OmsRefundAddressRef
  },
  data () {
    return {
      //当前用户店铺类型1:平台，2：自营，3：店铺，4：供应商
      shopType: Vue.ls.get(SHOP_TYPE),
      //当前用户部门code
      orgCode: Vue.ls.get(ORG_CODE),
      confirmLoading: false,
      mallRefuseVisible: false,
      refuseReason: '',
      shopAddressVisible: false,
      addressId: '',
      name: '',
      tel: '',
      postCode: '',
      addressName: '',
      def_addressId: '',
      def_name: '',
      def_tel: '',
      def_postCode: '',
      def_addressName: '',
      shopGoodRefuseVisible: false,
      mallLastAgreeVisible: false,
      refundPrice: 0,
      max_refund_amount: 0,
      mallLastRefuseVisible: false,
      description: '售后订单管理页面',
      selectRow: null,
      // 表头
      columns: [
        {
          title: '退款单号',
          align: "center",
          dataIndex: 'refundNo'
        },
        {
          title: '买家昵称',
          align: "center",
          dataIndex: 'uid',
          scopedSlots: { customRender: 'memberInfo' }
        },

        {
          title: '订单号',
          align: "center",
          dataIndex: 'orderNo'
        },
        {
          title: '商品信息',
          dataIndex: 'orderSkuId',
          scopedSlots: { customRender: 'goodInfo' }
        },
        {
          title: '店铺',
          align: "center",
          dataIndex: 'shopId',
          scopedSlots: { customRender: 'shopInfo' }
        },
        {
          title: '售后类型',
          align: "center",
          dataIndex: 'type',
          customRender: function (text) {
            return text == 1 ? "退货退款" : "仅退款"
          }
        },

        // {
        //   title: '订单金额',
        //   align: "right",
        //   dataIndex: 'orderSku',
        //   scopedSlots: { customRender: 'orderInfo' }
        // },
        // {
        //   title: '申请退款金额',
        //   align: "right",
        //   dataIndex: 'applyPrice',
        //   scopedSlots: { customRender: 'number' }
        // },
        {
          title: '退款金额',
          align: "right",
          dataIndex: 'refundPrice',
          scopedSlots: { customRender: 'number' }
        },

        {
          title: '创建时间',
          align: "center",
          dataIndex: 'createTime',
          customRender: function (text) {
            return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
          }
        },
        {
          title: '状态',
          align: "center",
          dataIndex: 'preStatus_dictText',
          scopedSlots: { customRender: 'preStatusSlot' }
        },

        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          fixed: "right",
          width: 147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      // 供应商表头
      columns1: [
        {
          title: '退款单号',
          align: "center",
          dataIndex: 'refundNo'
        },
        {
          title: '买家昵称',
          align: "center",
          dataIndex: 'uid',
          scopedSlots: { customRender: 'memberInfo' }
        },

        {
          title: '订单号',
          align: "center",
          dataIndex: 'orderNo'
        },
        {
          title: '商品信息',
          dataIndex: 'orderSkuId',
          scopedSlots: { customRender: 'goodInfo' }
        },
        // {
        //   title: '店铺',
        //   align: "center",
        //   dataIndex: 'shopId',
        //   scopedSlots: { customRender: 'shopInfo' }
        // },
        {
          title: '供货金额',
          align: "right",
          dataIndex: 'orderSku',
          scopedSlots: { customRender: 'orderInfo' }
        },
        {
          title: '状态',
          align: "center",
          dataIndex: 'preStatus_dictText',
          scopedSlots: { customRender: 'preStatusSlot' }
        },
        {
          title: '申请时间',
          align: "center",
          dataIndex: 'createTime',
          customRender: function (text) {
            return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
          }
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          fixed: "right",
          width: 147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: "/mallBase/omsOrderRefund/list",
        addrList: "/mallBase/omsRefundAddress/list",
        delete: "/mallBase/omsOrderRefund/delete",
        deleteBatch: "/mallBase/omsOrderRefund/deleteBatch",
        exportXlsUrl: "/mallBase/omsOrderRefund/exportXls",
        importExcelUrl: "mallBase/omsOrderRefund/importExcel",
      },
      dictOptions: {},
      type: null,//处理人类型：1:买家 2：店铺 3:平台
      isClose: null,//是否平台关闭
      closeReason: null//关闭原因
    }
  },
  created () {
    if (this.$route.query.id) {
      this.queryParam.uid = this.$route.query.id
    }
    if (this.$route.query.status) {
      this.queryParam.status = Number(this.$route.query.status)
    }

    this.loadData()
    this.getDefaultAddr()
  },

  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    searchReset () {
      if (this.queryParam.uid) {
        this.queryParam = {
          uid: this.queryParam.uid,
          status: this.queryParam.status
        }
      } else {
        this.queryParam = {}
      }

      this.loadData(1)
    },
    getDefaultAddr () {
      let self = this
      getAction("/mallBase/omsRefundAddress/list", { column: 'isTop', order: 'desc', pageNo: 1, pageSize: 1, isTop: 1 }).then(res => {
        if (res.success) {
          if (res.result.records.length > 0) {
            self.def_addressId = res.result.records[0].id
            self.def_name = res.result.records[0].name
            self.def_tel = res.result.records[0].tel
            self.def_postCode = res.result.records[0].postCode
            self.def_addressName = res.result.records[0].fullName
          }
        } else {
          this.$message.error(res.message)
        }
      })
    },
    addressSelect () {
      let self = this
      self.$refs.modalGoodsSet.visible = true
      self.$refs.modalGoodsSet.open()
    },
    modalGoodsOk (row) {
      const self = this
      self.addressId = row.id
      self.name = row.name
      self.tel = row.tel
      self.postCode = row.postCode
      self.addressName = row.fullName
    },
    initDictConfig () {
    },
    // 1-1.平台初审-通过 》 店铺处理-确认退款地址
    handleMallAgree (item) {
      var self = this
      self.$confirm({
        title: '操作提醒',
        content: '确定要同意退款吗?',
        onOk () {
          self.confirmLoading = true
          postAction('/mallBase/omsOrderRefund/mall-agree-one', {
            refundNo: item.refundNo
          }).then(res => {
            self.loadData()
          }).finally(() => {
            self.confirmLoading = false
          })
        },
        onCancel () {
          // console.log('Cancel')
        }
      })
    },
    // 1-2.平台初审-拒绝 》 待用户关闭或重新提交
    handleMallRefuse (item, type) {
      var self = this
      self.mallRefuseVisible = true
      self.refuseReason = ''
      self.selectRow = item
      if (type) {
        self.type = type
      }

    },
    handleMallRefuseOk () {
      var self = this
      if (!self.refuseReason) {
        self.$message.warning("请先输入拒绝原因")
        return
      }
      self.$confirm({
        title: '操作提醒',
        content: '确定要拒绝退款吗?',
        onOk () {
          self.confirmLoading = true
          postAction('/mallBase/omsOrderRefund/mall-refuse-one', {
            refundNo: self.selectRow.refundNo,
            refuseReason: self.refuseReason,
            type: self.type
          }).then(res => {
            self.loadData()
          }).finally(() => {
            self.mallRefuseVisible = false
            self.confirmLoading = false
            self.type = null
          })
        },
        onCancel () {
          // console.log('Cancel')
        }
      })
    },
    // 2-1.店铺处理-确认退货地址 》 待用户发货
    handleShopAddress (item) {
      var self = this
      self.shopAddressVisible = true
      self.addressId = self.def_addressId + ""
      self.name = self.def_name + ""
      self.tel = self.def_tel + ""
      self.postCode = self.def_postCode + ""
      self.addressName = self.def_addressName + ""
      self.selectRow = item
    },
    handleShopAddressOk () {
      var self = this
      if (!self.addressId) {
        self.$message.warning("请先选择地址")
        return
      }
      self.$confirm({
        title: '操作提醒',
        content: '确定已选择正确退货地址?',
        onOk () {
          self.confirmLoading = true
          postAction('/mallBase/omsOrderRefund/shop-address', {
            refundNo: self.selectRow.refundNo,
            addressId: self.addressId
          }).then(res => {
            self.loadData()
          }).finally(() => {
            self.shopAddressVisible = false
            self.confirmLoading = false
          })
        },
        onCancel () {
          // console.log('Cancel')
        }
      })
    },
    // 3-1.店铺处理-货物审核通过 》 平台终审
    handleShopGoodAgree (item) {
      var self = this
      self.$confirm({
        title: '操作提醒',
        content: '确定退回货物审核通过吗?',
        onOk () {
          self.confirmLoading = true
          postAction('/mallBase/omsOrderRefund/shop-good-agree', {
            refundNo: item.refundNo
          }).then(res => {
            self.loadData()
          }).finally(() => {
            self.confirmLoading = false
          })
        },
        onCancel () {
          // console.log('Cancel')
        }
      })
    },
    // 3-1.店铺处理-货物审核拒绝 》 平台终审
    handleShopGoodRefuse (item) {
      var self = this
      self.shopGoodRefuseVisible = true
      self.refuseReason = ''
      self.selectRow = item
    },
    handleShopGoodRefuseOk () {
      var self = this
      if (!self.refuseReason) {
        self.$message.warning("请先输入拒绝原因")
        return
      }
      self.$confirm({
        title: '操作提醒',
        content: '确定要拒绝退款吗?',
        onOk () {
          self.confirmLoading = true
          postAction('/mallBase/omsOrderRefund/shop-good-refuse', {
            refundNo: self.selectRow.refundNo,
            refuseReason: self.refuseReason
          }).then(res => {
            self.loadData()
          }).finally(() => {
            self.shopGoodRefuseVisible = false
            self.confirmLoading = false
          })
        },
        onCancel () {
          // console.log('Cancel')
        }
      })
    },
    // 4-1.平台终审-通过 》 退款订单关闭
    handleMallLastAgree (item, type, isClose) {
      var self = this
      self.mallLastAgreeVisible = true
      self.max_refund_amount = item.refundPrice
      self.refundPrice = item.refundPrice
      self.selectRow = item
      if (type) {
        self.type = type
      }
      if (isClose) {
        self.isClose = isClose
        self.closeReason = ""
      }
    },
    handleMallLastAgreeOk () {
      var self = this
      if (!self.refundPrice) {
        self.$message.success("请先输入退款金额")
        return
      }
      self.$confirm({
        title: '操作提醒',
        content: '确定要同意退款吗?',
        onOk () {
          self.confirmLoading = true
          postAction('/mallBase/omsOrderRefund/mall-agree-end', {
            refundNo: self.selectRow.refundNo,
            refundPrice: self.refundPrice,
            type: self.type,
            isClose: self.isClose,
            closeReason: self.closeReason
          }).then(res => {
            self.loadData()
          }).finally(() => {
            self.mallLastAgreeVisible = false
            self.confirmLoading = false
            self.type = null
          })
        },
        onCancel () {
          // console.log('Cancel')
        }
      })
    },
    // 4-2.平台终审-拒绝 》 待用户关闭
    handleMallLastRefuse (item, type) {
      var self = this
      self.mallLastRefuseVisible = true
      self.selectRow = item
      self.refuseReason = ''
      if (type) {
        self.type = type
      }
    },
    handleMallLastRefuseOk (item) {
      var self = this
      if (!self.refuseReason) {
        self.$message.warning("请先输入拒绝原因")
        return
      }
      self.$confirm({
        title: '操作提醒',
        content: '确定要拒绝退款吗?',
        onOk () {
          self.confirmLoading = true
          postAction('/mallBase/omsOrderRefund/mall-refuse-end', {
            refundNo: self.selectRow.refundNo,
            refuseReason: self.refuseReason,
            type: self.type
          }).then(res => {
            self.loadData()
          }).finally(() => {
            self.mallLastRefuseVisible = false
            self.confirmLoading = false
            self.type = null
          })
        },
        onCancel () {
          // console.log('Cancel')
        }
      })
    },

  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
.b-b {
  border-bottom: solid 1px #dddddd;
  text-align: left;
}
</style>
